﻿@model ProductViewModel

@{
    ViewBag.Title = "title";
    Layout = "../_Layout.cshtml";
}


<div class="list-group">
    @foreach (var urun in Model.Products)
    {
        <a class="list-group-item">

            <div class="button-group pull-right">
                @using (Ajax.BeginForm("AddToCart", "Cart", new AjaxOptions { LoadingElementId = "loading",OnBegin = "onBegin",OnSuccess = "onSuccess", UpdateTargetId = "cart" }))
                {
                    @Html.Hidden("productId", urun.ProductId)
                    <button type="submit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-plus"></i> @Word("Main.Cart.AddToCart")</button>
                }
            </div>

            <h4>@urun.ProductName</h4>

            <p>@urun.QuantityPerUnit</p>

            <p>@urun.UnitPrice.ToString("C")</p>
        </a>
    }

</div>

@Html.Pager(Model.PagingInfo)

@section Scripts
{
    <script type="text/javascript">

        function onBegin() {
            $("#dialog-notifications-success").hide();
            $("#dialog-notifications-danger").hide();
        }

        function onSuccess() {
            displayNotification("@Word("General.Success")", "success");
        }

    </script>
}